package com.survey.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.survey.common.annotation.Log;
import com.survey.common.core.controller.BaseController;
import com.survey.common.core.domain.AjaxResult;
import com.survey.common.enums.BusinessType;
import com.survey.system.domain.SurFollowup;
import com.survey.system.service.ISurFollowupService;
import com.survey.common.utils.poi.ExcelUtil;
import com.survey.common.core.page.TableDataInfo;

/**
 * 追问信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/system/followup")
public class SurFollowupController extends BaseController
{
    @Autowired
    private ISurFollowupService surFollowupService;

    /**
     * 查询追问信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:followup:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurFollowup surFollowup)
    {
        startPage();
        List<SurFollowup> list = surFollowupService.selectSurFollowupList(surFollowup);
        return getDataTable(list);
    }

    /**
     * 导出追问信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:followup:export')")
    @Log(title = "追问信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurFollowup surFollowup)
    {
        List<SurFollowup> list = surFollowupService.selectSurFollowupList(surFollowup);
        ExcelUtil<SurFollowup> util = new ExcelUtil<SurFollowup>(SurFollowup.class);
        util.exportExcel(response, list, "追问信息数据");
    }

    /**
     * 获取追问信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:followup:query')")
    @GetMapping(value = "/{followupId}")
    public AjaxResult getInfo(@PathVariable("followupId") Long followupId)
    {
        return success(surFollowupService.selectSurFollowupByFollowupId(followupId));
    }

    /**
     * 新增追问信息
     */
    @PreAuthorize("@ss.hasPermi('system:followup:add')")
    @Log(title = "追问信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SurFollowup surFollowup)
    {
        surFollowup.setCreateBy(getUsername());
        return toAjax(surFollowupService.insertSurFollowup(surFollowup));
    }

    /**
     * 修改追问信息
     */
    @PreAuthorize("@ss.hasPermi('system:followup:edit')")
    @Log(title = "追问信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurFollowup surFollowup)
    {
        surFollowup.setUpdateBy(getUsername());
        return toAjax(surFollowupService.updateSurFollowup(surFollowup));
    }

    /**
     * 删除追问信息
     */
    @PreAuthorize("@ss.hasPermi('system:followup:remove')")
    @Log(title = "追问信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{followupIds}")
    public AjaxResult remove(@PathVariable Long[] followupIds)
    {
        return toAjax(surFollowupService.deleteSurFollowupByFollowupIds(followupIds));
    }
}
